package com.simple.relaxed.manager.impl;

import com.simple.relaxed.anno.Mark;
import com.simple.relaxed.manager.AbstractManager;
import lombok.Data;

import java.lang.reflect.Method;

/**
 * 此类管理者，管理着异步任务以及其启动和完成时监听器
 */
@Mark(methodName = "getInstance")
public class AsyncTaskManager extends AbstractManager<String, AsyncTaskManager.Entry> {

    /**
     * 异步任务，开始监听器，完成监听器实体类。
     */
    @Data
    public static class Entry {

        private Object asyncInstance, beforeInstance, afterInstance;

        private Method asyncTask, beforeTask, afterTask;
    }

    private static AsyncTaskManager asyncTaskManager = new AsyncTaskManager();

    private AsyncTaskManager() {
        super();
    }

    public static AsyncTaskManager getInstance() {
        if (asyncTaskManager == null) {
            asyncTaskManager = new AsyncTaskManager();
        }
        return asyncTaskManager;
    }
}
